<?php

namespace app\admin\model\broker;

use think\Model;


class Sellershouse extends Model
{

    

    

    // 表名
    protected $name = 'sellers_house';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'sex_data_text',
        'decoration_standards_data_text',
        'mortgage_status_data_text',
        'residential_status_data_text',
        'sales_cycle_data_text',
        'certificate_processing_time_data_text',
        'pay_method_data_text',
        'number_of_properties_text',
        'create_time_text'
    ];
    

    
    public function getSexDataList()
    {
        return ['1' => __('Sex_data 1'), '2' => __('Sex_data 2')];
    }

    public function getDecorationStandardsDataList()
    {
        return ['1' => __('Decoration_standards_data 1'), '2' => __('Decoration_standards_data 2'), '3' => __('Decoration_standards_data 3'), '4' => __('Decoration_standards_data 4')];
    }

    public function getMortgageStatusDataList()
    {
        return ['1' => __('Mortgage_status_data 1'), '2' => __('Mortgage_status_data 2'), '3' => __('Mortgage_status_data 3'), '4' => __('Mortgage_status_data 4')];
    }

    public function getResidentialStatusDataList()
    {
        return ['1' => __('Residential_status_data 1'), '2' => __('Residential_status_data 2'), '3' => __('Residential_status_data 3')];
    }

    public function getSalesCycleDataList()
    {
        return ['1' => __('Sales_cycle_data 1'), '2' => __('Sales_cycle_data 2'), '3' => __('Sales_cycle_data 3'), '4' => __('Sales_cycle_data 4')];
    }

    public function getCertificateProcessingTimeDataList()
    {
        return ['1' => __('Certificate_processing_time_data 1'), '2' => __('Certificate_processing_time_data 2'), '3' => __('Certificate_processing_time_data 3'), '4' => __('Certificate_processing_time_data 4')];
    }

    public function getPayMethodDataList()
    {
        return ['1' => __('Pay_method_data 1'), '2' => __('Pay_method_data 2'), '3' => __('Pay_method_data 3')];
    }

    public function getNumberOfPropertiesList()
    {
        return ['1' => __('Number_of_properties 1'), '2' => __('Number_of_properties 2'), '3' => __('Number_of_properties 3'), '4' => __('Number_of_properties 4')];
    }


    public function getSexDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['sex_data']) ? $data['sex_data'] : '');
        $list = $this->getSexDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getDecorationStandardsDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['decoration_standards_data']) ? $data['decoration_standards_data'] : '');
        $list = $this->getDecorationStandardsDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getMortgageStatusDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['mortgage_status_data']) ? $data['mortgage_status_data'] : '');
        $list = $this->getMortgageStatusDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getResidentialStatusDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['residential_status_data']) ? $data['residential_status_data'] : '');
        $list = $this->getResidentialStatusDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getSalesCycleDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['sales_cycle_data']) ? $data['sales_cycle_data'] : '');
        $list = $this->getSalesCycleDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCertificateProcessingTimeDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['certificate_processing_time_data']) ? $data['certificate_processing_time_data'] : '');
        $list = $this->getCertificateProcessingTimeDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getPayMethodDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['pay_method_data']) ? $data['pay_method_data'] : '');
        $list = $this->getPayMethodDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getNumberOfPropertiesTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['number_of_properties']) ? $data['number_of_properties'] : '');
        $list = $this->getNumberOfPropertiesList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCreateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    protected function setCreateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
